package com.promise.jokerdream.database.entity

import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.Index
import androidx.room.PrimaryKey
import kotlinx.serialization.Serializable

/**
 * Room 实体类 - 任务配置
 * 关联到 TaskGroupConfigEntity
 */
@Serializable
@Entity(
    tableName = "task_config",
    foreignKeys = [
        ForeignKey(
            entity = TaskGroupConfigEntity::class,
            parentColumns = ["groupId"],
            childColumns = ["taskGroupId"],
            onDelete = ForeignKey.CASCADE
        )
    ],
    indices = [Index(value = ["taskId"], unique = true)]
)
data class TaskConfigEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Long = 0,
    val taskGroupId: Long, // 外键关联到 TaskGroupConfigEntity
    val taskId: String, // TaskConfig 的 id
    val taskName: String,
    val executionCount: Int,
    val taskLink: String,
    val enabled: Boolean = true
)

